package com.gitee.wsl.struct.language

import kotlinx.serialization.KSerializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

object LangSerializer : KSerializer<Lang> {
    override val descriptor = String.serializer().descriptor

    override fun deserialize(decoder: Decoder): Lang {
        return Lang.valueOf(decoder.decodeString())
    }

    override fun serialize(encoder: Encoder, value: Lang) {
        encoder.encodeString(value.code)
    }
}

typealias LangP = LangSerializer
